package zhouzhouyongche.model;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;

@Entity
@Table(uniqueConstraints={@UniqueConstraint(columnNames="busNumber")})
@DynamicInsert(true)
@DynamicUpdate(true)
public class Ticket implements Serializable{
	
	private static final long serialVersionUID = 1L;

	//主键
    private int id;
    private City startCity;
    private String busNumber;
    private PassengerStation startPassengerStation;
    private Site endSite;
    private City endCity;
    private Year year;
    private Month month;
    private Day day;
    private Hour hour;
    private Minute minute;
    private float price;
    //库存
    private int inventory;
    private String busType;
    private Set<Seat> seats;
    
    @Id
    @GeneratedValue(generator = "generator")
	@GenericGenerator(name = "generator", strategy = "identity")
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@OneToOne
	@JoinColumn(name = "startCity_id", nullable = false)
	public City getStartCity() {
		return startCity;
	}

	public void setStartCity(City startCity) {
		this.startCity = startCity;
	}

	@OneToOne
	@JoinColumn(name = "startPassengerStation_id", nullable = false)
	public PassengerStation getStartPassengerStation() {
		return startPassengerStation;
	}

	public void setStartPassengerStation(PassengerStation startPassengerStation) {
		this.startPassengerStation = startPassengerStation;
	}

	@OneToOne
	@JoinColumn(name = "endCity_id", nullable = false)
	public City getEndCity() {
		return endCity;
	}

	public void setEndCity(City endCity) {
		this.endCity = endCity;
	}

	@Column(nullable = false)
	public float getPrice() {
		return price;
	}

	public void setPrice(float price) {
		this.price = price;
	}

	@Column(nullable = false)
	public int getInventory() {
		return inventory;
	}

	public void setInventory(int inventory) {
		this.inventory = inventory;
	}

	@Column
	public String getBusType() {
		return busType;
	}

	public void setBusType(String busType) {
		this.busType = busType;
	}

	@OneToOne
	@JoinColumn(name = "endSite_id", nullable = false)
	public Site getEndSite() {
		return endSite;
	}

	public void setEndSite(Site endSite) {
		this.endSite = endSite;
	}

	@OneToOne
	@JoinColumn(name = "year_id")
	public Year getYear() {
		return year;
	}

	public void setYear(Year year) {
		this.year = year;
	}

	@OneToOne
	@JoinColumn(name = "month_id")
	public Month getMonth() {
		return month;
	}

	public void setMonth(Month month) {
		this.month = month;
	}

	@OneToOne
	@JoinColumn(name = "day_id")
	public Day getDay() {
		return day;
	}

	public void setDay(Day day) {
		this.day = day;
	}

	@OneToOne
	@JoinColumn(name = "hour_id")
	public Hour getHour() {
		return hour;
	}

	public void setHour(Hour hour) {
		this.hour = hour;
	}

	@OneToOne
	@JoinColumn(name = "minute_id")
	public Minute getMinute() {
		return minute;
	}

	public void setMinute(Minute minute) {
		this.minute = minute;
	}

	@OneToMany
	@JoinColumn(name = "ticket_id")
	public Set<Seat> getSeats() {
		return seats;
	}

	public void setSeats(Set<Seat> seats) {
		this.seats = seats;
	}

	@Column(nullable = false)
	public String getBusNumber() {
		return busNumber;
	}

	public void setBusNumber(String busNumber) {
		this.busNumber = busNumber;
	}
}
